require(['./config'], () => {
    require(['header', 'footer', 'jquery'], () => {
        class Login {
            constructor() {
                this.loginEvent()
            }
            loginEvent() {
                $(".join").on("click", function () {
                    let flag = false
                    let userEmail = $("#email").val()
                    let userPsd = $("#psd").val()

                    let storage = localStorage.getItem("userInfo") ? JSON.parse(localStorage.getItem("userInfo")) : []
                //    console.log( localStorage.getItem("userInfo"));
                   

                    if(storage != []){
                        flag = true
                        // alert("账号不存在，请注册")
                        // window.open('/html/register.html')
                    }
                    if(flag) {
                        storage.forEach(item => {
                            // let a = 
                            if (userEmail == item.email && userPsd == item.psd ) {
                                sessionStorage.setItem('email', userEmail)
                                    alert("登陆成功")
                                    window.open('/')
                            }else {
                                console.log(123);
                                alert("错误")
                            }
                        })
                    } else{
                        alert("账号不存在，请注册")
                        window.open('/html/register.html')
                    }
                    
                })
            }
        }
        return new Login()
    })
})